<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 11] DataOutputStream</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 16:35:26 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch11_12.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 11<br>The java.io Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch11_14.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>DataOutputStream</H1>

<H2>Name</H2>

DataOutputStream

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.87">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.DataOutputStream</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.FilterOutputStream</tt>
 

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.io.DataOutput</tt>

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.88">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>DataOutputStream</tt> class 
defines methods for writing primitive data types to an output stream in 
a machine-independent manner. Many of the methods of <tt CLASS=literal>DataOutputStream</tt> 
write a single primitive data type, in binary format, to an underlying 
output stream. All multibyte quantities are written in a format that stores 
the most significant byte as the first byte and the least significant byte 
as the last byte. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.89">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.io.DataOutputStream extends java.io.FilterOutputStream
                                      implements java.io.DataOutput {
  // Variables
  protected int written;
  // Constructors
  public DataOutputStream(OutputStream out);
  // Instance Methods
  public void flush();
  public final int size();
  public synchronized void write(int b);
  public synchronized void write(byte[] b, int off, int len);
  public final void writeBoolean(boolean v);
  public final void writeByte(int v);
  public final void writeBytes(String s);
  public final void writeChar(int v);
  public final void writeChars(String s);
  public final void writeDouble(double v);
  public final void writeFloat(float v);
  public final void writeInt(int v);
  public final void writeLong(long v);
  public final void writeShort(int v);
  public final void writeUTF(String str);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.90">Variables</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.116">written</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.142">protected int written</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The number of bytes that have been written to this output stream. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.91">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.117">DataOutputStream</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.143">public DataOutputStream(OutputStream out)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>out</tt><br>
<DD>

<P CLASS=para>
The output stream to 
use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>DataOutputStream</tt> 
that uses <tt CLASS=literal>out</tt> as its underlying 
stream. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.92">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.118">flush</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.144">public void flush() throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterOutputStream.flush()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method flushes the stream, forcing any buffered output to be written. 
The method calls the <tt CLASS=literal>flush()</tt> 
method of the underlying output stream. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.119">size</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.145">public final int size()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The number of bytes written. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the number of bytes that have been written to the stream 
(i.e., it returns the value of the variable <tt CLASS=literal>written</tt>). </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.120">write</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.146">public synchronized void write(int b) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
The value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterOutputStream.write(int)</tt> 

<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.write(int)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes the low-order eight bits of <tt CLASS=literal>b</tt> 
to the underlying stream as a <tt CLASS=literal>byte</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.147"><DIV CLASS=screen> <P> <PRE> public synchronized void write(byte b[], int off, int len) throws IOException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>b</tt><br>
<DD>

<P CLASS=para>
An array of bytes to write.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>off</tt><br>
<DD>

<P CLASS=para>
An offset into the byte array.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>len</tt><br>
<DD>

<P CLASS=para>
The number of bytes to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>FilterOutputStream.write(byte[], int, int)</tt> 

<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.write(byte[], int, int)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes <tt CLASS=literal>len</tt> bytes from the given array, starting <tt CLASS=literal>off</tt> elements from the beginning of the array, to the 
underlying stream. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.121">writeBoolean</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.148">public final void writeBoolean(boolean v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>boolean</tt> 
value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeBoolean()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
If <tt CLASS=literal>v</tt> is <tt CLASS=literal>true</tt>, 
this method writes a byte that contains the value <tt CLASS=literal>1</tt> 
to the underlying stream. If <tt CLASS=literal>v</tt> 
is <tt CLASS=literal>false</tt>, the method writes 
a byte that contains the value 0. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.122">writeByte</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.149">public final void writeByte(int v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeByte()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes an 8-bit <tt CLASS=literal>byte</tt> 
to the underlying stream, using the low-order eight bits of the given integer 
<tt CLASS=literal>v</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.123">writeBytes</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.150">public final void writeBytes(String s) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String </tt>to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeBytes()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes the characters in the given <tt CLASS=literal>String</tt> 
to the underlying stream as a sequence of 8-bit bytes. The high-order 
bytes of the characters in the string are ignored. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.124">writeChar</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.151">public final void writeChar(int v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeChar()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 16-bit <tt CLASS=literal>char</tt> 
to the underlying stream, using the low-order 16 bits of the given integer 
<tt CLASS=literal>v</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.125">writeChars</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.152">public final void writeChars(String s) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String </tt>to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeChars()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes the characters in the given <tt CLASS=literal>String</tt> 
object to the underlying stream as a sequence of 16-bit characters. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.126">writeDouble</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.153">public final void writeDouble(double v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>double</tt> 
value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeDouble()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 64-bit <tt CLASS=literal>double</tt> 
to the underlying stream. The <tt CLASS=literal>double</tt> 
value is converted to a <tt CLASS=literal>long</tt> 
using <tt CLASS=literal>doubleToLongBits()</tt> of 
<tt CLASS=literal>Double</tt>; the <tt CLASS=literal>long</tt> 
value is then written to the underlying stream as eight bytes with the 
high-order byte first. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.127">writeFloat</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.154">public final void writeFloat(float v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> 
value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeFloat()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 32-bit <tt CLASS=literal>float</tt> 
to the underlying stream. The <tt CLASS=literal>float</tt> 
value is converted to a <tt CLASS=literal>int</tt> 
using <tt CLASS=literal>floatToIntBits()</tt> of <tt CLASS=literal>Float</tt>; 
the <tt CLASS=literal>int</tt> value is then written 
to the underlying stream as four bytes with the high-order byte first. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.128">writeInt</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.155">public final void writeInt(int v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> 
value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeInt()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 32-bit <tt CLASS=literal>int</tt> 
to the underlying stream. The value is written as four bytes with the 
high-order byte first. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.129">writeLong</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.156">public final void writeLong(long v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> 
value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeLong()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 64-bit <tt CLASS=literal>long</tt> 
to the underlying stream. The value is written as eight bytes with the 
high-order byte first. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.130">writeShort</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.157">public final void writeShort(int v) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The value to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeShort()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes a 16-bit <tt CLASS=literal>short</tt> 
to the underlying stream, using the low-order two bytes of the given integer 
<tt CLASS=literal>v</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch11-REFSECT2-AUTOID.131">writeUTF</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch11-REFSECT3-AUTOID.158">public final void writeUTF(String str) throws IOException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>str</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String</tt> 
to write. </DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>IOException</tt><br>
<DD>

<P CLASS=para>
If 
any kind of I/O error occurs. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DataOutput.writeUTF()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method writes the given <tt CLASS=literal>String</tt> 
to the underlying stream using the UTF-8 encoding. First, two bytes are 
written as an unsigned <tt CLASS=literal>short</tt> 
value; this value specifies the number of bytes to follow. The value is 
the actual number of bytes in the UTF-8 encoding, not the length of the 
string. Then each character of the string is written as UTF-8 encoded bytes.

<P CLASS=para>
See <A HREF="appb_01.htm">Appendix B, <i>The UTF-8 Encoding</i></A> for more information on the
UTF-8 encoding.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.93">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Method</TH>
<TH ALIGN="LEFT">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>close()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>FilterOutputStream</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>equals(Object)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>hashCode()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>toString()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>write(byte[])</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>FilterOutputStream</tt></TD>
<TD ALIGN="LEFT">&nbsp;</TD>
<TD ALIGN="LEFT">&nbsp;</TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch11-REFSECT1-AUTOID.94">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>DataInputStream</tt>, 
<tt CLASS=literal>DataOutput</tt>, 
<tt CLASS=literal>Double</tt>, 
<tt CLASS=literal>FilterOutputStream</tt>, 
<tt CLASS=literal>Float</tt>, 
<tt CLASS=literal>IOException</tt>, 
<tt CLASS=literal>OutputStream</tt> 
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch11_12.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch11_14.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>DataOutput</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>EOFException</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
